﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CreditLine.aspx.cs" Inherits="CreditLine" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>    

            <asp:Panel ID="emptyPanel" runat="server" visible="false">
                <div align="center">
                    <h1>Liniile de creditare</h1>
                </div>
            </asp:Panel>

            <asp:Panel ID="allListPanel" runat="server" Visible="False">
                <asp:Button ID="newButton" runat="server" Text="Adauga nou" Width="230px"  onclick="newButton_Click"></asp:Button>
                <hr />
                <asp:GridView ID="listGridView" runat="server" 
                        EnableModelValidation="True" 
                        AutoGenerateColumns="False" 
                        CssClass="mGrid"
                        PagerStyle-CssClass="pgr"
                        AlternatingRowStyle-CssClass="alt"
                        AllowPaging="True"         
                        PageSize="10" 
                        onrowediting="listGridView_RowEditing" 
                        onpageindexchanging="listGridView_PageIndexChanging" 
                        onrowdeleting="listGridView_RowDeleting" >
                    <Columns>
                        <asp:BoundField DataField="LinesID"         HeaderText="LinesID"        HtmlEncode="False"   HeaderStyle-CssClass="HiddenColumn" ItemStyle-CssClass = "HiddenColumn"  />
                        <asp:BoundField DataField="Name"            HeaderText="Name"           HtmlEncode="False" />
                        <asp:BoundField DataField="Code"            HeaderText="Code"           HtmlEncode="false"/>
                        <asp:BoundField DataField="CurrencyID"      HeaderText="CurrencyID"     HtmlEncode="false" HeaderStyle-CssClass="HiddenColumn" ItemStyle-CssClass = "HiddenColumn" />
                        <asp:BoundField DataField="Currency"        HeaderText="Currency"       HtmlEncode="false" />
                        
                        <asp:TemplateField HeaderText="Start date">
                            <ItemTemplate>
                                <asp:Label ID="DateBeginLabel" runat="server" Text='<%# ((Eval("DateBegin") != null && Eval("DateBegin") is DateTime) ?  ((DateTime)Eval("DateBegin")).ToString(Constants.Constants.ISODateBackwardDotsFormat) : "") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>   
                        
                        <asp:TemplateField HeaderText="End date">
                            <ItemTemplate>
                                <asp:Label ID="DateEndLabel" runat="server" Text='<%# ((Eval("DateEnd") != null && Eval("DateEnd") is DateTime) ?  ((DateTime)Eval("DateEnd")).ToString(Constants.Constants.ISODateBackwardDotsFormat) : "") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>  

                        <asp:BoundField DataField="InitialAmount"   HeaderText="Initial Amount" HtmlEncode="false" />
                        <asp:BoundField DataField="RealRemainder"   HeaderText="Real Reminder"  HtmlEncode="false" />
                        <asp:BoundField DataField="AnticipatedRemainder"  HeaderText="Anticipated Remainder" HtmlEncode="false" />
                
                        <asp:ButtonField ButtonType="Button"  CommandName="Edit"      Text="Edit" />
                        <asp:ButtonField ButtonType="Button"  CommandName="Delete"    Text="Delete" />
                    </Columns>
                </asp:GridView>
            </asp:Panel>

            <asp:Panel ID="addNewEntryPanel" runat="server" Visible="False" >               
                <div class="module">
                    <div class="moduleHeader">Nou</div>
                    <div class="module_content">                        
                        <p>
                            <label>Name: </label>
                            <asp:TextBox ID="addNewNameTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>Code: </label>
                            <asp:TextBox ID="addNewCodeTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>Currency: </label>
                            <asp:DropDownList ID="addNewCurrencyDropDownList" runat="server"></asp:DropDownList>
                        </p> 
                        <p>
                            <label>Begin date: </label>
                            <asp:TextBox ID="addNewDateBeginTextBox" runat="server"></asp:TextBox>
                            <ajax:CalendarExtender ID="addNewDateBeginCalendarExtender" runat="server"  TargetControlID="addNewDateBeginTextBox" />
                        </p>
                        <p>
                            <label>End date: </label>
                            <asp:TextBox ID="addNewDateEndTextBox" runat="server"></asp:TextBox>
                            <ajax:CalendarExtender ID="addNewDateEndCalendarExtender" runat="server"  TargetControlID="addNewDateEndTextBox" />                   
                        </p>
                        <p>
                            <label>Initial Amount: </label>
                            <asp:TextBox ID="addNewInitialAmountTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>RealRemainder: </label>
                            <asp:TextBox ID="addNewRealRemainderTextBox" runat="server"></asp:TextBox>
                        </p>
                            <p>
                            <label>Anticipated remainder: </label>
                            <asp:TextBox ID="addNewAnticipatedRemainderTextBox" runat="server"></asp:TextBox>
                        </p>
                
                        <asp:Button ID="addNewSaveButton"  runat="server" Text="Save" onclick="addNewSaveButton_Click"   />
                        <asp:Button ID="addNewCancelButton" runat="server" Text="Cancel"  onclick="addNewCancelButton_Click"  />
                    </div>
                </div>
            </asp:Panel>

            <asp:Panel ID="editEntryPanel" runat="server" Visible="False">
                <div class="module">
                    <div class="moduleHeader">Modific</div>
                    <div class="module_content">                           
                        <p>
                            <label> ID: </label>
                            <asp:Label ID="linesIDLabel" runat="server" ></asp:Label>
                        </p>
                        <p>
                            <label>Nume: </label>
                            <asp:TextBox ID="editNameTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>Code: </label>
                            <asp:TextBox ID="editCodeTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>Currency: </label>
                            <asp:DropDownList ID="editCurrencyDropDownList" runat="server"></asp:DropDownList>
                        </p>
                        <p>
                            <label>Begin date: </label>
                            <asp:TextBox ID="editDateBeginTextBox" runat="server"></asp:TextBox>
                            <ajax:CalendarExtender ID="editDateBeginCalendarExtender" runat="server"  TargetControlID="editDateBeginTextBox" />
                        </p>
                        <p>
                            <label>End date: </label>
                            <asp:TextBox ID="editDateEndTextBox" runat="server"></asp:TextBox>
                            <ajax:CalendarExtender ID="editDateEndCalendarExtender" runat="server"  TargetControlID="editDateEndTextBox" />
                        </p>
                        <p>
                            <label>Initial Amount: </label>
                            <asp:TextBox ID="editInitialAmountTextBox" runat="server"></asp:TextBox>
                        </p>
                        <p>
                            <label>RealRemainder: </label>
                            <asp:TextBox ID="editRealRemainderTextBox" runat="server"></asp:TextBox>
                        </p>
                            <p>
                            <label>Anticipated remainder: </label>
                            <asp:TextBox ID="editAnticipatedRemainderTextBox" runat="server"></asp:TextBox>
                        </p>

                        <asp:Button ID="editSaveButton" runat="server" Text="Save" onclick="editSaveButton_Click"  />
                        <asp:Button ID="editCancelButton" runat="server" Text="Cancel" onclick="editCancelButton_Click"  />
                    </div>
                </div>
            </asp:Panel>
   
       </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

